﻿@model YouWei.Infrastructure.Entity.UserInfo

@{
    ViewBag.Title = "用户详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="content-header">
    <h1>
        用户管理
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active">用户详情</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <table class="table table-striped">
                        <tr>
                            <td>姓名</td>
                            <td>@Model.UserName</td>
                            <td>电话</td>
                            <td>@Model.Mobile</td>
                        </tr>
                        <tr>
                            <td>公司名称</td>
                            <td>@Model.CompanyName</td>
                            <td>职位</td>
                            <td>@Model.Position</td>
                        </tr>
                        <tr>
                            <td>邮箱</td>
                            <td>@Model.Email</td>
                            <td>座机</td>
                            <td>@Model.Telephone</td>
                        </tr>
                        <tr>
                            <td>微信号</td>
                            <td>@Model.WeChartNum</td>
                            <td>来源渠道</td>
                            <td>@Model.UserSence</td>
                        </tr>
                        <tr>
                            <td>地址</td>
                            <td>@Model.DAddress</td>
                            <td>创建时间</td>
                            <td>@Model.CreateDate</td>
                        </tr>
                        @*<tr>
                            <td>OpenID</td>
                            <td>@Model.OpenID</td>
                            <td>UnionID</td>
                            <td>@Model.UnionID</td>
                        </tr>*@
                        <tr>
                            <td>简介</td>
                            <td colspan="3">@Model.UserDesc</td>
                        </tr>
                    </table>
                </div>
                <div class="box-body table-responsive no-padding">
                    <div class="box box-primary">
                        <div class="box-header">
                            <div class="h4">子用户列表</div>
                        </div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-bordered table-hover body-table-head">
                                <thead>
                                    <tr>
                                        <th>
                                            用户名称
                                        </th>
                                        <th>
                                            电话
                                        </th>
                                        <th>
                                            微信号
                                        </th>
                                        <th>
                                            公司
                                        </th>
                                        <th>
                                            职位
                                        </th>
                                        <th>
                                            邮箱
                                        </th>
                                        <th>
                                            OpenID
                                        </th>
                                        <th>
                                            创建时间
                                        </th>
                                        <th class="t_c">
                                            操作
                                        </th>
                                    </tr>
                                </thead>
                                <tbody id="tbodylist"></tbody>
                            </table>
                            <div class="no-data" id="nodata" style="display:none;">
                                <div class="img-box"></div>
                                <div class="text">暂无数据</div>
                            </div>
                        </div>
                        <div class="box-footer clearfix" style="text-align:center;vertical-align:middle;">
                            <a class="btn btn-danger" href="@Url.Action("Index","User")">返回</a>
                        </div>
                        <!-- /.box-body -->
                        <!-- /.box -->
                    </div>
                </div>
            </div>
        </div>
</section>
@section scriptsBottom{
    <script src="@Url.Content("~/lib/art-template/template-web.js")"></script>
    <script id="dataItemTpl" type="text/html">
        {{each rows}}
        <tr>
            <td class="title">
                {{$value.UserName}}
            </td>
            <td class="title">
                {{$value.Mobile}}
            </td>
            <td class="title">
                {{$value.WeChartNum}}
            </td>
            <td>
                {{$value.CompanyName}}
            </td>
            <td>
                {{$value.Position}}
            </td>
            <td>
                {{$value.Email}}
            </td>
            <td>
                {{$value.OpenID}}
            </td>
            <td>
                {{$value.CreateDate}}
            </td>
            <td class="t_c">
                <button type="button" class="btn btn-info btn-xs" onclick="detail('{{$value.UserID}}')">微信信息</button>
            </td>
        </tr>
        {{/each}}
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            //分类
            childList();
        });

        //页码
        var pageIndex = 1;
        //查询
        function childList() {
            var url = '@Url.Action("ChildList", "User")' + "?page=" + pageIndex+"&userId="+@Model.UserID;
            //查询列表
            BMCW.ajax({
                url: url,
                type: 'GET',
                dataType: "json",
                success: function (dt) {
                    if (dt.total < 1) {
                        $("#nodata").show();
                        document.getElementById('tbodylist').innerHTML = "";
                        return;
                    }
                    $("#nodata").hide();
                    //模板渲染
                    var data = dt.rows;
                    var html = template('dataItemTpl', dt);
                    document.getElementById('tbodylist').innerHTML = html;
                    //分页显示
                    $('#pagination').twbsPagination("destroy");
                    $('#pagination').twbsPagination({
                        totalItems: dt.total,
                        visiblePages: 10,
                        pageSize: 10,
                        startPage: parseInt(pageIndex),
                        onPageClick: function (event, page) {
                            pageIndex = page;
                            childList();
                        }
                    });
                }
            });
        }

         //用户详情
        function detail(userid) {
            var url = '@Url.Action("Detail", "User")' + "?userId=" + userid;
            location.href = url;
        }
    </script>
}